package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyLifeCommentLike;
import com.laowang.project.system.service.MyLifeCommentLikeService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 评论点赞Controller
 *
 * @author laowang
 * @date 2023-04-25
 */
@Api(tags = "评论点赞接口")
@RestController
@RequestMapping("/commentLike")
public class MyLifeCommentLikeController extends BaseController {
    @Autowired
    private MyLifeCommentLikeService myLifeCommentLikeService;

    /**
     * 查询评论点赞列表
     */
    @ApiOperation(value = "查询评论点赞列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:commentLike:list')")
    @GetMapping("/list")
        public TableDataInfo list(MyLifeCommentLike myLifeCommentLike) {
        startPage();
        List<MyLifeCommentLike> list = myLifeCommentLikeService.selectMyLifeCommentLikeList(myLifeCommentLike);
        return getDataTable(list);
    }

    /**
     * 导出评论点赞列表
     */
    @ApiOperation(value = "导出评论点赞列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:commentLike:export')")
    @Log(title = "评论点赞", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyLifeCommentLike myLifeCommentLike) {
        List<MyLifeCommentLike> list = myLifeCommentLikeService.selectMyLifeCommentLikeList(myLifeCommentLike);
        ExcelUtil<MyLifeCommentLike> util = new ExcelUtil<MyLifeCommentLike>(MyLifeCommentLike.class);
        return util.exportExcel(list, "commentLike");
    }

    /**
     * 获取评论点赞详细信息
     */
    @ApiOperation(value = "获取评论点赞详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('system:commentLike:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myLifeCommentLikeService.selectMyLifeCommentLikeById(id));
    }

    /**
     * 新增评论点赞
     */
    @ApiOperation(value = "新增评论点赞",notes = "")
    @PreAuthorize("@ss.hasPermi('system:commentLike:add')")
    @Log(title = "评论点赞", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyLifeCommentLike myLifeCommentLike) {
        return toAjax(myLifeCommentLikeService.insertMyLifeCommentLike(myLifeCommentLike));
    }

    /**
     * 修改评论点赞
     */
    @ApiOperation(value = "修改评论点赞",notes = "")
    @PreAuthorize("@ss.hasPermi('system:commentLike:edit')")
    @Log(title = "评论点赞", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyLifeCommentLike myLifeCommentLike) {
        return toAjax(myLifeCommentLikeService.updateMyLifeCommentLike(myLifeCommentLike));
    }

    /**
     * 删除评论点赞
     */
    @ApiOperation(value = "删除评论点赞",notes = "")
    @PreAuthorize("@ss.hasPermi('system:commentLike:remove')")
    @Log(title = "评论点赞", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myLifeCommentLikeService.deleteMyLifeCommentLikeByIds(ids));
    }
}
